<template>
	<view class="content">
		<view class="wid100 " :style="'background: '+theme.main_color+';'" style="height: 250rpx;">
			<view style="height: 60rpx;"></view>
			<view class="textCen coFFF">
				<view class="foSi40" style="vertical-align: bottom;line-height: 40rpx;">
					<span>¥</span>
					<span class="fowe600 foSi60 mar-left10">{{you_money}}</span>
				</view>
				<view class="foSi20 mar-top20">可提现金额</view>
			</view>
		</view>
		<view class="wid90 mar bacFFF borRad20" style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);margin-top: -50rpx;">
			<view class="wid90 mar dis disAl disJuB" style="height: 113rpx;">
				<view class="dis disAl wid80">
					<span class="foSi40 fowe600 mar-right10">¥</span>
					<view class="wid85 dis disAl disJuC" style="border-bottom: 1rpx solid #E1DFDF;height: 55rpx;">
						<input class="wid90 foSi25" v-model="money" type="digit" placeholder="最低提现1元" placeholder-style="color: #A3A3A3;"/>
					</view>
				</view>
				<view class="dis disAl disJuC foSi20 fowe600 borRad40" @click="quanbu" style="width: 132rpx;height: 46rpx;"
				 :style="'border: 2rpx solid '+theme.main_color+';color: '+theme.main_color+';'">全部提现</view>
			</view>
		</view>
		<view class="mar-top40 wid90 mar borRad40" style="box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0,0,0,0.1);padding: 30rpx 0;">
			<view class="wid90 mar">
				<view style="height: 10rpx;"></view>
				<view class="fowe800 foSi30" style="line-height: 40rpx;">提现方式</view>
				<block v-for="(item,index) in with_method" :key="index">
					<view v-if="item == '1'" class="dis disAl disJuB hei60 mar-top30" @click="xuan = item">
						<view class="dis disAl">
							<image src="../../static/weixin.png" style="width: 48rpx;height: 39rpx;"></image>
							<view class="mar-left20 foSi25 fowe600">微信</view>
						</view>
						<view v-if="xuan == item" class="dis disAl disJuC borRad50"
							style="width: 26rpx;height: 26rpx;" :style="'border: 1rpx solid '+theme.main_color+';'">
							<view class="borRad50" :style="'background-color: '+theme.main_color+';'"
								style="width: 14rpx;height: 14rpx;"></view>
						</view>
						<view v-if="xuan != item" class="dis disAl disJuC borRad50" style="width: 26rpx;height: 26rpx;border: 1rpx solid #818181;"></view>
					</view>
					<view v-if="item == '2'" class="dis disAl disJuB hei60 mar-top20" @click="xuan = item">
						<view class="dis disAl">
							<image src="../../static/zhifubao.png" style="width: 48rpx;height: 39rpx;"></image>
							<view class="mar-left20 foSi25 fowe600">支付宝</view>
							<!-- <view class="mar-left20 foSi20" style="color: #00AD27;">去绑定</view> -->
						</view>
						<view v-if="xuan == item" class="dis disAl disJuC borRad50" :style="'border: 1rpx solid '+theme.main_color+';'"
							style="width: 26rpx;height: 26rpx;">
							<view class="borRad50" :style="'background-color: '+theme.main_color+';'" style="width: 14rpx;height: 14rpx;"></view>
						</view>
						<view v-if="xuan != item" class="dis disAl disJuC borRad50" style="width: 26rpx;height: 26rpx;border: 1rpx solid #818181;"></view>
					</view>
					<view v-if="item == '3'" class="dis disAl disJuB hei60 mar-top20" @click="xuan = item">
						<view class="dis disAl">
							<image src="../../static/zhuanzhang.png" style="width: 39rpx;height: 42rpx;"></image>
							<view class="mar-left20 foSi25 fowe600">线下转账</view>
						</view>
						<view v-if="xuan == item" class="dis disAl disJuC borRad50" :style="'border: 1rpx solid '+theme.main_color+';'"
							style="width: 26rpx;height: 26rpx;">
							<view class="borRad50" :style="'background-color: '+theme.main_color+';'" style="width: 14rpx;height: 14rpx;"></view>
						</view>
						<view v-if="xuan != item" class="dis disAl disJuC borRad50" style="width: 26rpx;height: 26rpx;border: 1rpx solid #818181;"></view>
					</view>
				</block>
			</view>
		</view>
		<view style="height: 120rpx;"></view>	
		<view class="mar borRad40 dis disAl disJuC coFFF foSi35 hei86" @click="tixian"
			style="width: 511rpx;" :style="'background-color: '+theme.main_color+';'">立即提现</view>
		<view style="height: 50rpx;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				xuan: 0,
				money: '',
				shenfen: 1,
				type : 1,
				id: null,
				you_money: 0.00,
				with_method: [],
				theme: null
			}
		},
		onLoad(option) {
			this.theme = uni.getStorageSync('theme')
			uni.setNavigationBarColor({
				frontColor: '#000000',
				backgroundColor: this.theme.main_color,//底部背景色
			})
			this.shenfen = option.shenfen
			if(option.type){
				this.type = option.type
			}
			
			this.id = option.id
			if(this.shenfen == 1){
				this.id = uni.getStorageSync('tech_id')
			}else if(this.shenfen == 2){
				this.id = uni.getStorageSync('distr_id')
			}else if(this.shenfen == 3){
				this.id = uni.getStorageSync('agent_id')
			}
			this.getList()
			
		},
		methods: {
			
			
			tixian(){
				var that = this;
				if(this.you_money <= 0){
					this.money = null
					return uni.showToast({
						title: "暂无提现金额",
						//将值设置为 success 或者直接不用写icon这个参数
						icon: 'error',
						//显示持续时间为 2秒
						duration: 2000
					})
				}
				if(!that.money){return uni.showToast({title: '请输入提现金额',icon: 'error',duration: 2000})}
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/withdrawal/apply_with',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						iden_type: that.shenfen,
						price_type: that.type,
						pid: that.id,
						way: that.xuan,
						price: that.money
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'success',
								//显示持续时间为 2秒
								duration: 2000
							})
							setTimeout(()=>{
								uni.navigateBack(1)
							},1000)
							
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
				
			},
			getList(){
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/withdrawal/way_list',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						iden_type: that.shenfen,
						price_type: that.type,
						pid: that.id
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.you_money = result.data.usermoney
							that.with_method = result.data.with_method
							that.xuan = that.with_method[0]
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
				
			},
			quanbu(){
				if(this.you_money > 0){
					this.money = this.you_money
				}else{
					uni.showToast({
						title: "暂无提现金额",
						//将值设置为 success 或者直接不用写icon这个参数
						icon: 'error',
						//显示持续时间为 2秒
						duration: 2000
					})
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {}
</style>
